package com.link.base.core.basic.interceptors.mybatis.system;


import com.link.core.kafka.KafkaTemplateFacotry;
import com.link.core.kafka.conf.KafkaEnv;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * @Author: qinxuegang
 * @Description:
 * @Date: 2018/12/24 14:45
 */

public class KafkaSender {
    private static final Logger logger = LogManager.getLogger(KafkaSender.class);
    public static final String TRACK_TOPIC = KafkaEnv.getTrackTopic();

    public static void sendInfo(String topic, String stack) {
        boolean flag = KafkaEnv.isEnabled();
        if (flag) {
            try {
                logger.info("已推送kafka信息");
                KafkaTemplateFacotry.send(topic, stack);
            } catch (Exception e) {
                KafkaEnv.setEnabled(false);
                logger.error(e.getMessage());
            }
        } else {
            logger.info("kafka server is not avilabel!");
        }
    }

}
